package com.example.demo.mapper;

import com.example.demo.entity.RoadConnect;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * m
 *
 * @author ws
 * @since 2023-08-24
 */
@Mapper
public interface RoadConnectMapper {
    @Select("SELECT * FROM road_connect")
    @Results({
            @Result(property = "fromCross", column = "from_cross"),
            @Result(property = "toCross", column = "to_cross"),
            @Result(property = "outEdge", column = "out_edge"),
            @Result(property = "inEdge", column = "in_edge"),
            @Result(property = "speedLimit", column = "speed_limit"),
            @Result(property = "distance", column = "distance"),
            @Result(property = "path", column = "path")
    })
    List<RoadConnect> getAllRoadConnects();

//    @Select("SELECT * FROM road_connect_1")
    @Select("SELECT * FROM road_connect_cross_copy_path")
    @Results({
            @Result(property = "fromCross", column = "from_cross"),
            @Result(property = "toCross", column = "to_cross"),
            @Result(property = "outEdge", column = "out_edge"),
            @Result(property = "inEdge", column = "in_edge"),
            @Result(property = "speedLimit", column = "speed_limit"),
            @Result(property = "distance", column = "distance"),
            @Result(property = "path", column = "path")
    })
    List<RoadConnect> getAllRoadConnects1();

    @Select("SELECT * FROM road_connect_cross_copy")
    @Results({
            @Result(property = "fromCross", column = "from_cross"),
            @Result(property = "toCross", column = "to_cross"),
            @Result(property = "outEdge", column = "out_edge"),
            @Result(property = "inEdge", column = "in_edge"),
            @Result(property = "speedLimit", column = "speed_limit"),
            @Result(property = "distance", column = "distance"),
            @Result(property = "path", column = "path")
    })
    List<RoadConnect> getAllRoadConnectCross();
    /**
     * 批量插入
     * @param roadConnects 路口关系
     */
    void insertRoadConnectBatch(List<RoadConnect> roadConnects); // 添加批量插入方法


    // 添加批量更新方法，注意参数类型为 List<RoadConnect>
    void updateRoadConnectBatch(List<RoadConnect> roadConnects);

    void insertRoadConnectBatch1(List<RoadConnect> allRoadConnectCross);


    @Select("SELECT * FROM road_connect_cross_copy_path where from_cross = #{from_cross}")
    @Results({
            @Result(property = "fromCross", column = "from_cross"),
            @Result(property = "toCross", column = "to_cross"),
            @Result(property = "outEdge", column = "out_edge"),
            @Result(property = "inEdge", column = "in_edge"),
            @Result(property = "speedLimit", column = "speed_limit"),
            @Result(property = "distance", column = "distance"),
            @Result(property = "path", column = "path")
    })
    List<RoadConnect> getRoadPath(@Param("from_cross") Integer from_cross);
}
